package com.example.demo.config;

import com.example.demo.sharding.DBShardingStrategy;
import com.example.demo.sharding.TableShardingStrategy;
import com.mybatisflex.core.datasource.DataSourceManager;
import com.mybatisflex.core.table.DynamicTableProcessor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BootstrapConfig implements ApplicationRunner {

    /**
     * 数据源分片
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        //DataSourceManager.setDataSourceShardingStrategy(new DBShardingStrategy());
    }

    /**
     * 动态分表
     */
    //@Bean
    public DynamicTableProcessor dynamicTableProcessor(){
        return new TableShardingStrategy();
    }
}
